package org.witsoft.localmqexample.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.witsoft.localmq.ConfigManager;
import org.witsoft.localmq.MessageManager;
import org.witsoft.localmq.MqInstanceFactory;
import org.witsoft.localmq.impl.DefaultConfigManager;

/**
 * @ClassName: LocalMqAutoConfig
 * @Description:
 * @Author: Colin.Lin
 * @Date: 2020/12/27 3:33 AM
 * @Version 1.0
 **/
@Configuration
public class LocalMqAutoConfig {

    @Bean
    public MqInstanceFactory mqInstanceFactory(){
        ConfigManager configManager  = new LocalMqConfigManager();
        MqInstanceFactory factory = new MqInstanceFactory(configManager);
        return factory;
    }

    @Bean
    public MessageManager messageManager(MqInstanceFactory factory){
        MessageManager messageManager = factory.getMessageManager();
        return messageManager;
    }

}
